fix: Strengthen error handling in qwenOAuth2.ts to prevent unhandled 'error' event#3481
fix: Strengthen error handling in qwenOAuth2.ts to prevent unhandled 'error' event#3481Ojhaharsh wants to merge 3 commits intoQwenLM:mainfrom
Conversation
| @@ -8,7 +8,7 @@ import crypto from 'crypto'; | |||
| import path from 'node:path'; | |||
| import { promises as fs } from 'node:fs'; | |||
| import * as os from 'os'; | |||
There was a problem hiding this comment.
[Suggestion] ChildProcess is only used as a type here, so this should be a type-only import to satisfy the repo's lint rule.
| import * as os from 'os'; | |
| import type { ChildProcess } from 'node:child_process'; |
— gpt-5.4 via Qwen Code /review
|
Hi @wenshao, This PR contains the robust error handling fix for Status: ✅ Lint Fixed: Updated This addresses the root cause of the crash you identified. It is designed to be merged alongside PR #1675 (which handles the utility/test updates). Ready for your final approval! |
Hi @wenshao,
As suggested in your review of #1675, this PR addresses the root cause of the crash reported in issue #1674
The Issue
The crash (
Unhandled 'error' event) occurs inpackages/core/src/qwen/qwenOAuth2.tswhen theopenpackage fails to spawn a browser process (common on RISC-V/OrangePi headless environments).The Fix
I updated the
launchBrowserhelper function to:childProcessis valid before attaching listeners.childProcess.on('error')listener immediately afterawait open()to minimize race conditions.try/catchAND the event listener, logging gracefully viadebugLoggerinstead of crashing.This implements your suggestion to "attach the error listener before the child has a chance to emit."
Relation to PR #1675
This is the second part of the split you requested:
qwenOAuth2.ts.--
(Fixes #1674)
Ready for review!